package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 新增员工
     * @param employee
     */
    @Insert("insert into employee(id,name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user) " +
            "values" +
            "(#{id},#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insertEmployee(Employee employee);

    /**
     * 获取员工列表分页
     * @param employeePageQueryDTO
     * @return
     */
    Page<Employee> selectEmployeeList(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 更新员工状态
     * @param employee 员工实体对象
     */
    void update(Employee employee);

    /**
     * 根据员工id获取员工属性
     * @param id 员工id
     * @return 员工
     */
    @Select("select * from employee where id = #{id}")
    Employee selectEmployeeById(Long id);
}
